﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Soket_MMTNC_Server
{
    /// <summary>
    /// Interaction logic for login.xaml
    /// </summary>
    public partial class login : Window
    {
        public login()
        {
            InitializeComponent();
        }
        User u = new User();
        private void btThoat_Click(object sender, RoutedEventArgs e)
        {
            //Environment.Exit(0);
            Application.Current.Shutdown();
        }

        private void btDongY_Click(object sender, RoutedEventArgs e)
        {
            if (txt_username.Text.Trim()==""||pwb_password.Password.Trim()=="")
            {
                lb_username.Visibility = Visibility.Visible;
                lb_password.Visibility = Visibility.Visible;
            }
            else
            {
                if (u.Login(txt_username.Text.Trim(), pwb_password.Password))
                {
                    this.Close();
                    MainWindow.me.Run();
                }
                else
                {
                    tbl_login.Text = "Your login attempt was not successful. Please try again!";
                }
            }
        }
    }
}
